﻿@model  ElingOA6_Admin_DSJCJ.Model.Calendar
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    <title>日历编辑</title>
    @if (false)
    {
    
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/regex.js", true)" type="text/javascript"></script>
    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.Button, Theme = DevExpressHelper.Theme },
                        new StyleSheet { ExtensionType = ExtensionType.PopupControl, Theme = DevExpressHelper.Theme },
                          new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }


)
    @Html.DevExpress().GetScripts(
             new Script { ExtensionType = ExtensionType.ListBox },

                            new Script { ExtensionType = ExtensionType.PopupControl },
                             new Script { ExtensionType = ExtensionType.Button }

    )
    <script type="text/javascript">
        function OnLookSave() {
            var str = ""
            if ($("#FBeginDate").val().match(/^\d{4}-\d{2}-\d{2}/) == null) {
                str += "请填写正确的开始时间";

            }
            if ($("#FEndDate").val().match(/^\d{4}-\d{2}-\d{2}/) == null) {
                str += "请填写正确的结束时间";

            }
            if (FContents.GetText() == null | $.trim(FContents.GetText()) == "" | $.trim(FTitle.GetText()) == "" | FTitle.GetText() == null) {
                alert(str + "主题或内容不能为空");
            }
            else {

                $.ajax({
                    type: "POST",
                    url: '@Url.Action("Save", "Calendar")',
                    data: $('#form_query1').serialize(),
                    dataType: "json",
                    error: function (data) {
                        alert(data.responseText);
                    },
                    success: function (data) {
                        //  popContent.codeOK(data);

                        alert("更新成功");
                        window.close();
                    }
                });
                // form_query1.submit();
            }

        }
        function LookDelete() {
            var id = $("#FCalendarID").val();
            $.ajax({
                type: 'POST',
                url: '@Url.Action("DeleteCalendarOne", "Calendar")',
                data: { cid: id },
                success: function (result) {

                    if (result == "ok") {
                        alert("删除成功");
                        window.close();
                    }
                    else {
                        alert(result);
                    }
                }
            });
        }
        function setifcheckedallday(s, e) {
            if (s.GetChecked()) {
                // var stime = ASPxClientDateEdit.Cast("FBeginDate").GetText();
                var stime = $("#FBeginDate").val();

                var sout = stime.match(/^\d{4}-\d{2}-\d{2}/);
                if (sout != null) {
                    //ASPxClientDateEdit.Cast("FBeginDate").SetText(sout + " 00:00:00");
                    $("#hstime").val(stime);
                    $("#FBeginDate").val(sout + " 00:00");
                }
                //    var etime = ASPxClientDateEdit.Cast("FEndDate").GetText();
                var etime = $("#FEndDate").val();
                $("#hetime").val(etime);
                var eout = etime.match(/^\d{4}-\d{2}-\d{2}/);
                if (eout != null) {
                    $("#hetime").val(etime);
                    //  ASPxClientDateEdit.Cast("FEndDate").SetText(eout + " 00:00:00");
                    $("#FEndDate").val(eout + " 00:00");
                }
            }
            else {
                // ASPxClientDateEdit.Cast("FBeginDate").SetText($("#hstime").val());
                // ASPxClientDateEdit.Cast("FEndDate").SetText($("#hetime").val());
                if ($("#hstime").val() != "" & $("#hstime").val() != null) {
                    $("#FBeginDate").val($("#hstime").val());
                }

                if ($("#hetime").val() != null & $("#hetime").val() != "") {
                    $("#FEndDate").val($("#hetime").val());
                }
            }
        }
    </script>
</head>
<body bgcolor="#B6D6FF">
    @using (Html.BeginForm("Save", "Calendar", FormMethod.Post, new { id = "form_query1" }))
    {
         @Html.Hidden("hstime", "")
        @Html.Hidden("hetime", "")
        @Html.Hidden("FCalendarID", Model.FCalendarID);
        <table cellpadding="10" cellspacing="0" style="width: 100%; height: 285px; margin-top: 30px;">
            <tr>
                <td style="padding-right: 5px;">
                    @Html.DevExpress().Label(
                    settings =>
                    {
                        settings.AssociatedControlName = "FTitle";
                        settings.Text = "标题:";
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).GetHtml()
                </td>
                <td colspan="4" style="width: 100%">
                    @Html.DevExpress().TextBox(
                    settings =>
                    {
                        settings.Name = "FTitle";

                        // settings.ClientEnabled = false;
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).Bind(Model.FTitle).GetHtml()
                </td>
            </tr>
            <tr>
                <td style="white-space: nowrap; padding-right: 20px;">
                    @Html.DevExpress().Label(
                    settings =>
                    {
                        settings.AssociatedControlName = "StartTime";
                        settings.Text = "开始时间:";
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).GetHtml()
                </td>
                <td colspan="1">
                    <input type="text"   value="@Model.FBeginDate.ToString("yyyy-MM-dd HH:mm")" id="FBeginDate" name="FBeginDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" class="Wdate" style="width:170px"/>
                    @*  @Html.DevExpress().TextBox(
                    settings =>
                    {
                        settings.Name = "sTime";
                        settings.ClientEnabled = false;
                        settings.Text = @Model.FBeginDate.ToString("yyyy-MM-dd HH:mm:ss");
                        settings.Width = System.Web.UI.WebControls.Unit.Pixel(175);
                    }).GetHtml()*@
                </td>
                <td style="white-space: nowrap; padding-right: 2px;" colspan="2">
                    <table>
                        <tr>
                            <td style="white-space: nowrap; padding-right: 15px; padding-left: 20px;">
                                @Html.DevExpress().Label(
                    settings =>
                    {
                        settings.AssociatedControlName = "EndTime";
                        settings.Text = "结束时间:";
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).GetHtml()
                            </td>
                            <td>
                                <input type="text"  value="@Model.FEndDate.ToString("yyyy-MM-dd HH:mm")" id="FEndDate" name="FEndDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" class="Wdate" style="width:170px"/>
                                @*    @Html.DevExpress().TextBox(
                    settings =>
                    {
                        settings.Name = "ETime";
                        settings.ClientEnabled = false;
                        settings.Text = @Model.FEndDate.ToString("yyyy-MM-dd HH:mm:ss");
                        settings.Width = System.Web.UI.WebControls.Unit.Pixel(175);
                    }).GetHtml()*@
                            </td>
                            <td style="padding-left: 30px">
                                @Html.DevExpress().CheckBox(

        settings =>
        {
            settings.Name = "FIsAllDayEvent";
            settings.Text = "全天事件";
            // settings.ClientEnabled = false;
            settings.Checked = Model.FIsAllDayEvent == "Y" ? true : false;
            settings.Width = System.Web.UI.WebControls.Unit.Pixel(180);
            settings.Properties.ClientSideEvents.CheckedChanged = "function(s, e){setifcheckedallday(s ,e)}";
        }).GetHtml()
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="white-space: nowrap; padding-right: 20px;">
                    @Html.DevExpress().Label(
                    settings =>
                    {
                        settings.AssociatedControlName = "tixin";
                        settings.Text = "提醒:";
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).GetHtml()
                </td>
                <td>
                    @Html.DevExpress().ComboBox(
                settings =>
                {
                    // settings.ClientEnabled = false;
                    settings.Name = "rmdcombobox";
                    settings.Properties.TextField = "Text";
                    settings.Properties.ValueField = "Value";
                    settings.Width = System.Web.UI.WebControls.Unit.Pixel(175);

                }).BindList(new List<SelectListItem> { 
                           new SelectListItem { Text = "无", Value = "none" }, 
                           new SelectListItem { Text = "0分钟", Value = "0m" },

                           new SelectListItem { Text = "5分钟", Value = "5m" },
                           new SelectListItem { Text = "10分钟", Value = "10m" },
                           new SelectListItem { Text = "15分钟", Value = "15m" },
                           new SelectListItem { Text = "30分钟", Value = "30m" },
                           new SelectListItem { Text = "1小时", Value = "1h" },
                             new SelectListItem { Text = "3小时", Value = "3h" },
                               new SelectListItem { Text = "5小时", Value = "5h" },
                                 new SelectListItem { Text = "10小时", Value = "10h" },
                                  new SelectListItem { Text = "1天", Value = "1d" },
                                   new SelectListItem { Text = "2天", Value = "2d" },
                                    new SelectListItem { Text = "3天", Value = "3d" },
                                     new SelectListItem { Text = "5天", Value = "5d" },
                                     new SelectListItem { Text = "10天", Value = "10d"} 
     }).Bind(Model.WakeStr).GetHtml()
                </td>
                <td style="white-space: nowrap; padding-right: 20px;" colspan="2">
                    <table>
                        <tr>
                            <td style="white-space: nowrap; padding-right: 28px; padding-left: 22px;">
                                @Html.DevExpress().Label(
                    settings =>
                    {
                        settings.AssociatedControlName = "yxj";
                        settings.Text = "优先级:";
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).GetHtml()
                            </td>
                            <td>
                                @Html.DevExpress().ComboBox(
                settings =>
                {
                    settings.Name = "pricombobox";
                    settings.Properties.TextField = "Text";
                    settings.Properties.ValueField = "Value";
                    //  settings.ClientEnabled = false;
                    settings.Width = System.Web.UI.WebControls.Unit.Pixel(175);

                }).BindList(new List<SelectListItem> { 
                         
                           new SelectListItem { Text = "低", Value = "3" },

                           new SelectListItem { Text = "中", Value = "2" },
                           new SelectListItem { Text = "高", Value = "1" }
                         
     }).Bind(Model.FPri).GetHtml()
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    @Html.DevExpress().Label(
                    settings =>
                    {
                        settings.AssociatedControlName = "Description";
                        settings.Text = "内容:";
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).GetHtml()
                </td>
                <td colspan="3">
                    @Html.DevExpress().Memo(
                    settings =>
                    {
                        settings.Name = "FContents";
                        settings.Properties.Rows = 2;
                        settings.ShowModelErrors = true;
                        // settings.ClientEnabled = false;
                        settings.Height = System.Web.UI.WebControls.Unit.Pixel(100);
                        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    }).Bind(Model.FContents).GetHtml()
                </td>
            </tr>
        </table>

        <table cellpadding="0" cellspacing="0" style="width: 100%; height: 35px;">
            <tr>
                
                            <td align="center">
                                @Html.DevExpress().Button(
                                settings =>
                                {
                                    settings.Name = "Apply";
                                    settings.Text = "确定";
                                    settings.Width = System.Web.UI.WebControls.Unit.Pixel(91);
                                    settings.ClientSideEvents.Click = "OnLookSave";

                                }).GetHtml()
                            </td>

                            
                            <td align="center">
                                @Html.DevExpress().Button(
                                settings =>
                                {
                                    settings.Name = "Cancel";
                                    settings.Text = "取消";
                                    settings.ClientSideEvents.Click = "function(s, e){ window.returnValue ='back';window.close(); }";
                                    settings.Width = System.Web.UI.WebControls.Unit.Pixel(91);
                                }).GetHtml()
                            </td>
                            <td align="center">
                                @Html.DevExpress().Button(
                                settings =>
                                {
                                    settings.Name = "Delete";
                                    settings.Text = "删除";
                                    settings.Width = System.Web.UI.WebControls.Unit.Pixel(91);
                                    //  settings.ClientVisible = ViewBag.delvisible;

                                    settings.ClientSideEvents.Click = "function(s, e){ LookDelete(); }";
                                }).GetHtml()
                            </td>
                        
            </tr>
        </table>
        <table cellpadding="0" cellspacing="0" style="width: 100%;">
            <tr>
                <td style="width: 100%;" align="left">
                    @Html.DevExpress().SchedulerStatusInfo(
                    settings =>
                    {
                        settings.Name = "schedulerStatusInfo";
                        settings.Priority = 1;
                        settings.SchedulerName = "scheduler";
                    }).GetHtml()
                </td>
            </tr>
        </table>
    }
</body>
</html>
